FUNDAMENTAL THEOREM OF DIFFERENTIAL CALCULUS

puntos[f_,a_,b_]:=Level[Cases[Plot[f[x],{x,a,b}],_Line,-1],{3}]; 
imag [i_,f_,{a_,b_,n_},tipo_]:=Apply[If[tipo=="sup",Max,Min],
Flatten[puntos[f,a+(i-1)(b-a)/n,a+i(b-a)/n][[All, 2]]]];
sumaImag[i_,f_,{a_,b_,n_},tipo_]:=
Module[{j},Sum[imag[j,f,{a,b,n},tipo],{j,1,i,1}]];
bloque[i_,f_,{a_,b_,n_},tipo_]:=Append[Append[
If[i==1,Prepend[{{a+(i-1)(b-a)/n,imag[i,f,{a,b,n},tipo]}},{a,0}],
{{a+(i-1)(b-a)/n,imag[i,f,{a,b,n},tipo]}}],
{a+i(b-a)/n,imag[i,f,{a,b,n},tipo]}], 
If[i<n,{a+i(b-a)/n,imag[i+1,f,{a,b,n},tipo]},{a+i(b-a)/n,0}]];
sumaBloqueLinea[i_,f_,{a_,b_,n_},tipo_]:=
{{a+(i-1)(b-a)/n,sumaImag[i-1,f,{a,b,n},tipo]*(b-a)/n},
{a+(i-1)(b-a)/n,sumaImag[i,f,{a,b,n},tipo]*(b-a)/n},
{a+(i)(b-a)/n,sumaImag[i,f,{a,b,n},tipo]*(b-a)/n}};
sumaR[f_,{a_,b_,n_},tipo_]:={
Polygon[Flatten[Table[bloque[i,f,{a,b,n},tipo],{i,1,n} ],1]]};
sumaRline[f_,{a_,b_,n_},tipo_]:={
Line[Flatten[Table[bloque[i,f,{a,b,n},tipo],{i,1,n} ],1]]};
funArealine[f_,{a_,b_,n_},tipo_]:={
Line[Flatten[Table[sumaBloqueLinea[i,f,{a,b,n},tipo],{i,1,n} ],1]]};
tasaVar[f_,{a_,b_,n_},tipo_]:={Module[{i},Table[ Point[
{a+((2i+1)/2)(b-a)/n,
(sumaImag[i+1,f,{a,b,n},tipo]-sumaImag[i,f,{a,b,n},tipo])}],
{i,1,n-1}]]};
int[f_]:=Function[y,Evaluate[Integrate[f[y],y]]];
nombresFunciones:={"(x^2)","ln (x+1)","10-((e^x)/10) ","5/(x+1)","sen (x)"};
f:={(#^2)&,(Log[#+1])&,(10-1/10E^#)&,(5/(#+1))& ,(Sin[#])&};
functionButtons =Map[#[[1]]-> #[[2]]&,
Transpose[{Range[Length[nombresFunciones]],nombresFunciones}]];

Manipulate[
If[g=="Riemann Sums",Grid[{
{Show[{Plot[f[[ff]][x],{x,a,b},PlotLabel->Style["(∫_a^b) f",16],
AxesLabel->{Style["x ∈ [a,b]"],Style["f(x)"]},
PlotStyle->{RGBColor[.1,.4,.1],Thickness[.005]},
Filling->Axis,FillingStyle->RGBColor[.7,.8,.7],
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{150,150}]}]},
{Show[{Plot[f[[ff]][x],{x,a,b},
PlotLabel->Style["(∑_(i = 1)^n) \!\(\*SubscriptBox[\(Min\), \(\(\\ \)\(i\)\)]\)(((b - a))/n)",16],
AxesLabel->{Style["(Subscript[x, i]) ∈ [a,b]"],Style["\!\(\*SubscriptBox[\(Min\), \(\(\\ \)\(i\)\)]\)"]},
PlotStyle->{RGBColor[.1,.5,.1],Thickness[.005]},
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}],
Graphics[{
Black,Thickness[.005],sumaRline[f[[ff]],{a,b,n},"inf"], 
RGBColor[.5,.5,.2,.5],sumaR[f[[ff]],{a,b,n},"inf"]},
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}]
}]},
{Show[{Plot[f[[ff]][x],{x,a,b},
PlotLabel->Style["(∑_(i = 1)^n) \!\(\*SubscriptBox[\(Max\), \(\(\\ \)\(i\)\)]\)(((b - a))/n)",16],
AxesLabel->{Style["(Subscript[x, i]) ∈ [a,b]"],Style["\!\(\*SubscriptBox[\(Max\), \(\(\\ \)\(i\)\)]\)"]},
PlotStyle->{RGBColor[.1,.5,.1],Thickness[.005]},
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}],
Graphics[{
Black,Thickness[.005],sumaRline[f[[ff]],{a,b,n},"sup"], 
RGBColor[.8,.5,.2,.5],sumaR[f[[ff]],{a,b,n},"sup"]},
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}]
}]}
},Spacings->{0,1}],
If[g=="Function Area",Grid[{
{Show[{Plot[(int[f[[ff]]][x]-int[f[[ff]]][a]),{x,a,b},PlotLabel->Style["F(x)=(∫_a^x) f",16],
PlotStyle->{Cyan,Thickness[.005]},
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{150,150}]}]},
{Show[{Plot[{int[f[[ff]]][x]-int[f[[ff]]][a]},{x,a,b},
PlotLabel->Style["\!\(\*SubscriptBox[UnderscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\) = (∑_(j = 1)^i) \!\(\*SubscriptBox[\(Min\), \(\(\\ \)\(j\)\)]\) ((b - a)/n)",16],
PlotStyle->{Cyan,Thickness[.005]},
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}],
Graphics[{PointSize[.015],RGBColor[.1,.5,.5],Thickness[.008],
funArealine[f[[ff]],{a,b,n},"inf"]},
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}]
}]},
{Show[{Graphics[{PointSize[.015],RGBColor[.1,.1,.5],Thickness[.008],
funArealine[f[[ff]],{a,b,n},"sup"]},
PlotLabel->Style["\!\(\*SubscriptBox[OverscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\) = (∑_(j = 1)^i) \!\(\*SubscriptBox[\(Max\), \(\(\\ \)\(j\)\)]\) ((b - a)/n)",16],
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}],
Plot[{int[f[[ff]]][x]-int[f[[ff]]][a]},{x,a,b},
PlotStyle->{Cyan,Thickness[.005]},
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}]
}]}
},Spacings->{0,1}],
Grid[{
{Show[{Plot[{(int[f[[ff]]][x]-int[f[[ff]]][a]),f[[ff]][x]},{x,a,b},
PlotStyle->{Cyan,RGBColor[.1,.5,.1],Thickness[.005]},PlotLabel->Style["F '(x) = f(x)",16],
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{150,150}]
}]},
{Show[{ Graphics[{PointSize[.015],
RGBColor[.3,.1,.3],tasaVar[f[[ff]],{a,b,n},"inf"]},
PlotLabel->Style["(\!\(\*SubscriptBox[UnderscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\) - \!\(\*SubscriptBox[UnderscriptBox[\(S\), \(_\)], \(\(\\ \)\(i - 1\)\)]\))/((b - a)/n) = \!\(\*SubscriptBox[\(Min\), \(\(\\ \)\(i\)\)]\) ",16],
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}],
Plot[f[[ff]][x],{x,a,b},
PlotStyle->{RGBColor[0,.5,0],Thickness[.006]},
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}]
}]},
{Show[{ Graphics[{PointSize[.015],
RGBColor[.3,.1,.3],tasaVar[f[[ff]],{a,b,n},"sup"]},
PlotLabel->Style["(\!\(\*SubscriptBox[OverscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\) - \!\(\*SubscriptBox[OverscriptBox[\(S\), \(_\)], \(\(\\ \)\(i - 1\)\)]\))/((b - a)/n) = \!\(\*SubscriptBox[\(Max\), \(\(\\ \)\(i\)\)]\)",16],
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}],
Plot[f[[ff]][x],{x,a,b},PlotStyle->{RGBColor[0,.5,0],Thickness[.006]},
Axes->True,AxesOrigin->{0,0},AspectRatio->.8,ImageSize->{240,240}]
}]}
},Spacings->{0,1}]
]],
Style["  ""Fundamental Theorem",Bold,FontSize->16],
Style["",FontSize->4],
Style["  ""of Differential Calculus",Bold,FontSize->16],
Style["  ",Bold,FontSize->14,FontColor->RGBColor[1,0,0]],
Style[ " ""F(x) = (∫_a^x) f  \[Implies]  F'(x) = f(x)", FontSize->18,Orange],
Delimiter,
Style["Function: f",Bold,FontSize->12],
Style["",FontSize->4],
{{ff,1,"f"},functionButtons,ControlType->PopupMenu},
Style["",FontSize->8],
Style["Integration interval: [a,b]",Bold,FontSize->12],
{{a,0},0,b-.01,.001,Appearance->"Labeled"},
{{b,2Pi},a+.01,2Pi,.001,Appearance->"Labeled"},
Style["",FontSize->8],
Style["Number of subintervals: n",Bold,FontSize->12],
{{n,6},6,30,2,Appearance->"Labeled"},
Delimiter,
Style["Graphics",Bold,FontSize->12],
{{g,"Riemann Sums"},{"Riemann Sums","Function Area","Rates of Variation"}},
Style["",FontSize->8],

Dynamic[
If[g=="Riemann Sums",
Grid[{{Show[{  {Graphics[{
Text[Style["\!\(\*SubscriptBox[\(Mín\), \(\(\\ \\ \)\(i\)\)]\)",Bold,FontColor->Black],
{-.8,imag[If[ff<3,(10/2+2) , (10/2-1)],f[[ff]],{a,b,10},"inf"]}],
Text[Style["(((b - a))/n)(i-1)        (((b - a))/n)i",Bold,FontColor->Black],
{If[ff<3,a+(10/2+1)(b-a)/10 , a+(10/2-2)(b-a)/10]+.3,
-.5*imag[If[ff<3,(10/2+2) , (10/2-1)],f[[ff]],{a,b,10},"inf"]}],
Black,Thickness[.008],sumaRline[f[[ff]],
{If[ff<3,a+(10/2+1)(b-a)/10 , a+(10/2-2)(b-a)/10],
If[ff<3,a+(10/2+2)(b-a)/10 , a+(10/2-1)(b-a)/10],1},"inf"], 
RGBColor[.5,.5,.2,.5],sumaR[f[[ff]],
{If[ff<3,a+(10/2+1)(b-a)/10 , a+(10/2-2)(b-a)/10],
If[ff<3,a+(10/2+2)(b-a)/10 , a+(10/2-1)(b-a)/10],1},"inf"],
Black,Dashed,Thickness[.008],Line[{
{0,imag[If[ff<3,10/2+2 ,10/2-1],f[[ff]],{a,b,10},"inf"]},
{If[ff<3,a+(10/2+2)(b-a)/10, a+(10/2-2)(b-a)/10],
imag[If[ff<3,(10/2+2) , (10/2-1)],f[[ff]],{a,b,10},"inf"]}}]},
Axes->True,Ticks->None,AxesOrigin->{0,0},AspectRatio->.8,
ImageSize->{200,160}]},
Plot[f[[ff]][x],{x,a,b},
PlotStyle->{RGBColor[.1,.5,.1],Thickness[.005]},
Axes->True,Ticks->None,AxesOrigin->{0,0},AspectRatio->.8,
ImageSize->{200,160}]}]},
{Style[" ""(∑_(i = 1)^n) \!\(\*SubscriptBox[\(Min\), \(\(\\ \)\(i\)\)]\)(((b - a))/n)  <  (∫_a^b) f ",
FontSize->14,FontColor->RGBColor[.5,.5,.2]]},
{Style[" "" (∫_a^b) f <  (∑_(i = 1)^n) \!\(\*SubscriptBox[\(Max\), \(\(\\ \)\(i\)\)]\)(((b - a))/n)",
FontSize->14,FontColor->RGBColor[.6,.4,.1]]}
},Spacings->{0,3}],
If[g=="Function Area",Grid[{ {Show[{  {Graphics[{
Text[Style["\!\(\*SubscriptBox[UnderscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\)",FontColor->RGBColor[.1,.5,.5],Bold],
{-2.1,
sumaImag[If[ff<4,(10/2+3) , (10/2-2)],
f[[ff]],{a,b,10},"inf"]*(b-a)/10}],
Text[Style["F(\!\(\*SubscriptBox[\(x\), \(\(\\ \)\(i\)\)]\))",FontColor->Black,Bold,FontColor->Black],
{-1,
(int[f[[ff]]][
If[ff<4,a+(10/2+3)(b-a)/10 , a+(10/2-2)(b-a)/10]]-int[f[[ff]]][a])}],
Text[Style["\!\(\*SubscriptBox[\(x\), \(\(\\ \)\(i\)\)]\)",FontColor->Black,Bold],
{If[ff<4,a+(10/2+3)(b-a)/10 , a+(10/2-2)(b-a)/10]+.2,
-.4*sumaImag[If[ff<4,(10/2+3) , (10/2-2)],f[[ff]],{a,b,10},"inf"]*(b-a)/10}],
{RGBColor[.1,.5,.5],Dashed,Thickness[.005],
Line[{
{0,sumaImag[If[ff<4,10/2+3 , 10/2-2],f[[ff]],{a,b,10},"inf"]*
(b-a)/10},
{If[ff<4,a+(10/2+2)(b-a)/10 , a+(10/2-3)(b-a)/10],
sumaImag[If[ff<4,10/2+3 , 10/2-2],f[[ff]],{a,b,10},"inf"]*
(b-a)/10}}]
},

{Dashed,Black,Thickness[.005],
Line[{
{0,(int[f[[ff]]]
[If[ff<4,a+(10/2+3)(b-a)/10 , a+(10/2-2)(b-a)/10]]-int[f[[ff]]][a])},
{If[ff<4,a+(10/2+3)(b-a)/10 , a+(10/2-2)(b-a)/10],
(int[f[[ff]]]
[If[ff<4,a+(10/2+3)(b-a)/10, a+(10/2-2)(b-a)/10]]-int[f[[ff]]][a])}}],
Line[{
{If[ff<4,a+(10/2+3)(b-a)/10 , a+(10/2-2)(b-a)/10],
-.2*sumaImag[If[ff<4,(10/2+3) , (10/2-2)],
f[[ff]],{a,b,10},"inf"]*(b-a)/10},
{If[ff<4,a+(10/2+3)(b-a)/10 , a+(10/2-2)(b-a)/10],
(int[f[[ff]]]
[If[ff<4,a+(10/2+3)(b-a)/10 , a+(10/2-2)(b-a)/10]]-int[f[[ff]]][a])}}]
},
RGBColor[.1,.5,.5],Thickness[.008],Line[{
Append[Prepend[sumaBloqueLinea[If[ff<4,(10/2+3) , (10/2-2)],
f[[ff]],{a,b,10},"inf"],
{If[ff<4,a+(10/2+2)(b-a)/10 , a+(10/2-3)(b-a)/10],0}],
{If[ff<4,a+(10/2+3)(b-a)/10 , a+(10/2-2)(b-a)/10],0} ]}]
},Axes->True,Ticks->None,AxesOrigin->{0,0},AspectRatio->.8,
ImageSize->{200,160}],
Plot[(int[f[[ff]]][x]-int[f[[ff]]][a]),{x,a,b},
PlotStyle->{Cyan,Thickness[.005]},
Axes->True,AxesOrigin->{0,0},Ticks->None,AspectRatio->.8,
ImageSize->{200,160}]}
}]},
{Style["  ""\!\(\*SubscriptBox[UnderscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\) = (∑_(j = 1)^i) \!\(\*SubscriptBox[\(Min\), \(\(\\ \)\(j\)\)]\) ((b - a)/n)  <  F(\!\(\*SubscriptBox[\(x\), \(\(\\ \)\(i\)\)]\)) = (∫_a^(Subscript[x, i])) f ",
FontSize->14,FontColor->RGBColor[.1,.5,.5]]},
{Style["",FontSize->4]},
{Style["  ""F(\!\(\*SubscriptBox[\(x\), \(\(\\ \)\(i\)\)]\)) = (∫_a^(Subscript[x, i])) f  <  \!\(\*SubscriptBox[OverscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\) = (∑_(j = 1)^i) \!\(\*SubscriptBox[\(Max\), \(\(\\ \)\(j\)\)]\) ((b - a)/n)",
FontSize->14,FontColor->RGBColor[.1,.1,.5]]}
},Spacings->{0,2}],
(* Tasas de Variación *)

Grid[{
{Style["",FontSize->4]},
{Style["\!\(\*SubscriptBox[UnderscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\) = (∑_(j = 1)^i) \!\(\*SubscriptBox[\(Min\), \(\(\\ \)\(j\)\)]\)((b - a)/n)  ;  \!\(\*SubscriptBox[OverscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\) = (∑_(j = 1)^i) \!\(\*SubscriptBox[\(Max\), \(\(\\ \)\(j\)\)]\)((b - a)/n)" ,
FontSize->12,FontColor->RGBColor[.3,.1,.3]]},
{Show[{{Graphics[{
Text[Style["tan(\!\(\*SubscriptBox[UnderscriptBox[\(α\), \(_\)], \(\(\\ \)\(i\)\)]\))",Bold,RGBColor[.3,.1,.3],10],
{-2.8,(sumaImag[If[ff<4,10/2+3 , 10/2-2],
f[[ff]],{a,b,10},"inf"]*(b-a)/10
-sumaImag[If[ff<4,10/2+2 , 10/2-3],
f[[ff]],{a,b,10},"inf"]*(b-a)/10)/((b-a)/10)}],
Text[Style["\!\(\*SubscriptBox[UnderscriptBox[\(α\), \(_\)], \(\(\\ \)\(i\)\)]\)",RGBColor[.3,.1,.3],Bold,12],
{If[ff<4,a+(10/2+4)(b-a)/10 , a+(10/2-1)(b-a)/10]+1.1,
sumaImag[If[ff<4,10/2+4 , 10/2-1],
f[[ff]],{a,b,10},"inf"]*(b-a)/10}],
Text[Style["\!\(\*SubscriptBox[\(x\), \(\(\\ \)\(i\)\)]\)",FontColor->Black,Bold],
{If[ff<4,a+(10/2+5/2)(b-a)/10 , a+(10/2-5/2)(b-a)/10],
-.4*sumaImag[If[ff<4,(10/2+3) , (10/2-2)],f[[ff]],{a,b,10},"inf"]*(b-a)/10}],
Text[Style["f(\!\(\*SubscriptBox[\(x\), \(\(\\ \)\(i\)\)]\))",FontColor->Black,Bold,FontColor->Black],
{-.8,f[[ff]][If[ff<4,a+(10/2+5/2)(b-a)/10 , a+(10/2-5/2)(b-a)/10]]}],
Text[Style["\!\(\*SubscriptBox[UnderscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\)",Black,Bold,FontColor->Black],
{-.8,sumaImag[If[ff<4,10/2+4 , 10/2-1],f[[ff]],{a,b,10},"inf"]*
(b-a)/10}],
Text[Style["\!\(\*SubscriptBox[UnderscriptBox[\(S\), \(_\)], \(\(\\ \)\(i - 1\)\)]\)",Black,Bold,FontColor->Black],
{-.8,sumaImag[If[ff<4,10/2+3 , 10/2-2],f[[ff]],{a,b,10},"inf"]*
(b-a)/10}],
{Dashed,Black,Thickness[.005],
Line[{
{0,sumaImag[If[ff<4,10/2+4 , 10/2-1],f[[ff]],{a,b,10},"inf"]*
(b-a)/10},
{If[ff<4,a+(10/2+3)(b-a)/10 , a+(10/2-2)(b-a)/10],
sumaImag[If[ff<4,10/2+4 , 10/2-1],f[[ff]],{a,b,10},"inf"]*
(b-a)/10}}],
Line[{
{0,sumaImag[If[ff<4,10/2+3 , 10/2-2],f[[ff]],{a,b,10},"inf"]*
(b-a)/10},
{If[ff<4,a+(10/2+2)(b-a)/10 , a+(10/2-3)(b-a)/10],
sumaImag[If[ff<4,10/2+3 , 10/2-2],f[[ff]],{a,b,10},"inf"]*
(b-a)/10}}],
Line[{
{0,f[[ff]]
[If[ff<4,a+(10/2+5/2)(b-a)/10 , a+(10/2-5/2)(b-a)/10]]},
{If[ff<4,a+(10/2+3)(b-a)/10 , a+(10/2-2)(b-a)/10],
f[[ff]]
[If[ff<4,a+(10/2+5/2)(b-a)/10, a+(10/2-5/2)(b-a)/10]]}}],
Line[{
{If[ff<4,a+(10/2+5/2)(b-a)/10 , a+(10/2-5/2)(b-a)/10],
-.2*sumaImag[If[ff<4,(10/2+3) , (10/2-2)],
f[[ff]],{a,b,10},"inf"]*(b-a)/10},
{If[ff<4,a+(10/2+5/2)(b-a)/10 , a+(10/2-5/2)(b-a)/10],
f[[ff]]
[If[ff<4,a+(10/2+5/2)(b-a)/10 , a+(10/2-5/2)(b-a)/10]]}}],
PointSize[.025],
Point[{
If[ff<4,a+(10/2+5/2)(b-a)/10 , a+(10/2-5/2)(b-a)/10],
f[[ff]]
[If[ff<4,a+(10/2+5/2)(b-a)/10 , a+(10/2-5/2)(b-a)/10]]
}]
},
{RGBColor[.3,.1,.3],Thickness[.01],
Line[{
{If[ff<4,a+(10/2+2)(b-a)/10 , a+(10/2-3)(b-a)/10],
sumaImag[If[ff<4,10/2+3 , 10/2-2],
f[[ff]],{a,b,10},"inf"]*(b-a)/10},
{If[ff<4,a+(10/2+2)(b-a)/10 , a+(10/2-3)(b-a)/10],
sumaImag[If[ff<4,10/2+3 , 10/2-2],
f[[ff]],{a,b,10},"inf"]*(b-a)/10}+
2.5*{(b-a)/10 ,
(sumaImag[If[ff<4,10/2+4 , 10/2-1],
f[[ff]],{a,b,10},"inf"]*(b-a)/10
-sumaImag[If[ff<4,10/2+3 , 10/2-2],
f[[ff]],{a,b,10},"inf"]*(b-a)/10)} }],
Line[{
{If[ff<4,a+(10/2+2)(b-a)/10 , a+(10/2-3)(b-a)/10],
sumaImag[If[ff<4,10/2+3 , 10/2-2],
f[[ff]],{a,b,10},"inf"]*(b-a)/10},
{If[ff<4,a+(10/2+2)(b-a)/10 , a+(10/2-3)(b-a)/10],
sumaImag[If[ff<4,10/2+3 , 10/2-2],
f[[ff]],{a,b,10},"inf"]*(b-a)/10}+
1.1*{If[ff<4,a+(10/2+2)(b-a)/10 , a+(10/2-1)(b-a)/10],
0}}],
Dashed,Thickness[.005],
Line[{
{0,(sumaImag[If[ff<4,10/2+3, 10/2-2],
f[[ff]],{a,b,10},"inf"]*(b-a)/10
-sumaImag[If[ff<4,10/2+2 , 10/2-3],
f[[ff]],{a,b,10},"inf"]*(b-a)/10)/((b-a)/10)},
{If[ff<4,a+(10/2+5/2)(b-a)/10 , a+(10/2-5/2)(b-a)/10],
(sumaImag[If[ff<4,10/2+3 , 10/2-2],
f[[ff]],{a,b,10},"inf"]*(b-a)/10
-sumaImag[If[ff<4,10/2+2 , 10/2-3],
f[[ff]],{a,b,10},"inf"]*(b-a)/10)/((b-a)/10)}
}],
PointSize[.025],
Point[{If[ff<4,a+(10/2+5/2)(b-a)/10 , a+(10/2-5/2)(b-a)/10],
(sumaImag[If[ff<4,10/2+3 , 10/2-2],
f[[ff]],{a,b,10},"inf"]*(b-a)/10
-sumaImag[If[ff<4,10/2+2 , 10/2-3],
f[[ff]],{a,b,10},"inf"]*(b-a)/10)/((b-a)/10)}]
},
Black,Thickness[.004],Line[{
sumaBloqueLinea[If[ff<4,(10/2+3) , (10/2-2)],
f[[ff]],{a,b,10},"inf"],
sumaBloqueLinea[If[ff<4,(10/2+4) , (10/2-1)],
f[[ff]],{a,b,10},"inf"]}]
},Axes->True,Ticks->None,AxesOrigin->{0,0},AspectRatio->.8,
ImageSize->{200,160}  ]},
Plot[{(int[f[[ff]]][x]-int[f[[ff]]][a]),f[[ff]][x]},{x,a,b},
PlotStyle->{Cyan,RGBColor[.1,.5,.1],Thickness[.008]},
Axes->True,Ticks->None,AxesOrigin->{0,0},AspectRatio->.8,
ImageSize->{200,160}]
}]},
{Style["tan(\!\(\*SubscriptBox[UnderscriptBox[\(α\), \(_\)], \(\(\\ \)\(i\)\)]\)) = \!\(\*FractionBox[\(\*SubscriptBox[UnderscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\\  - \\ \*SubscriptBox[UnderscriptBox[\(S\), \(_\)], \(\(\\ \)\(i - 1\)\)]\), \(\((b - a)\)/n\)]\) = \!\(\*SubscriptBox[\(Min\), \(\(\\ \)\(i\)\)]\) < f(\!\(\*SubscriptBox[\(x\), \(\(\\ \)\(i\)\)]\))" ,FontSize->14,
FontColor->RGBColor[.3,.1,.3]]},
{Style[" f(\!\(\*SubscriptBox[\(x\), \(\(\\ \)\(i\)\)]\)) < tan(\!\(\*SubscriptBox[OverscriptBox[\(α\), \(_\)], \(\(\\ \)\(i\)\)]\)) = \!\(\*FractionBox[\(\*SubscriptBox[OverscriptBox[\(S\), \(_\)], \(\(\\ \)\(i\)\)]\\  - \\ \*SubscriptBox[OverscriptBox[\(S\), \(_\)], \(\(\\ \)\(i - 1\)\)]\), \(\((b - a)\)/n\)]\) = \!\(\*SubscriptBox[\(Max\), \(\(\\ \)\(i\)\)]\)" ,FontSize->14,
FontColor->RGBColor[.3,.1,.3]]}
},Spacings->{0,2}]
]]],
SaveDefinitions->True,ControlPlacement->Left]

a)  The area of the region bounded by the horizontal axis, the graph of a positive and bounded function f, and the vertical lines through (a,0) and (b,0), is denoted by (∫_a^b)f and is called integral of the function f on [a,b].
b) If the function is positive on some subintervals and negative on other, the (∫_a^b)f is the difference of the sum of the areas of the positive regions and the sum of the areas of the negative regions.
c) The (∫_a^b)f can be approximated by rectangles with bases defined by a partition of the interval [a,b] in n subintervals, and heights defined by the maximum and minimum of the function in each of the subintervals. The more subintervals has the partition, better is the approximation. 
d) Considering the integration limit b  as a variable x, we can define a new function F(x)=(∫_a^x)f. The Fundamental Theorem of Differential Calculus says that, if it exits, the derivative of F is f and, for this, it is sufficient the continuity of f. 
e) The statement can be observed, by  confirming that the integral function F(x) can be approximated by the function defined, for each x, adding the areas of the rectangles over the subintervals previous to x. 
f) When the number of subintervals is increased, the rate of variation, in each subinterval, of this function approximation tends to the value of the original function.
g) If the partition is symmetric (all the subintervals with the same length), 
the result f) follow immediately. The rate of variation of the function approximation, obtained with  the rectangles of minimum height, for each subinterval is the minimum of the function f on it. 
And the obtained with the rectangles of maximum height, is the maximum of f on it.

luis.valero@mac.com